package sg.edu.nus.iss.vmcs.customer;

import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/*
 * Copyright 2003 ISS.
 * The contents contained in this document may not be reproduced in any
 * form or by any means, without the written permission of ISS, other
 * than for the purpose for which it has been supplied.
 *
 */

/**
 * This control object monitors the selection of drink (drink brand) by a
 * customer in the Customer Panel. It performs an action in correspondence to
 * the drink selected.
 * 
 * @version 1.0 11 Oct 2008
 * @author Toh Kim Huat
 */

public class DrinkSelectionListener implements ActionListener {
	
	/**
	 * Transaction controller
	 */
	private TransactionController transactionController;

	/**
	 * This constructor creates an instance of the object
	 * 
	 * @param transactionController
	 *            The transaction controller which created this object
	 */
	public DrinkSelectionListener(TransactionController transactionController) {
		this.transactionController = transactionController;
	}
	
	public void actionPerformed(ActionEvent e) {
		Button source = (Button) e.getSource();
		String actionCommand = source.getActionCommand();
		int identifier = Integer.parseInt(actionCommand);
		transactionController.startTransaction(identifier);
	}

}
